/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JP_RegistraAccion.java
 *
 * Created on Jul 15, 2009, 4:51:39 PM
 */

package gui;
import delegate.GestionDelegate;
import controlacciones.ejb3.entity.TbArea;
import controlacciones.ejb3.pojo.TableBeanBinding_DatosReaperturas;
import helper.JP_Utiles_PanelModelo;
import helper.JP_Utiles_PanelBotonesMantenimiento;
import helper.Utiles_MensajesDialogo;
import java.awt.BorderLayout;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Task;
import controlaccionescomercial.ControlAccionesComercialApp;
import helper.Utiles_Fecha_Cliente;
import java.math.BigInteger;
import javax.swing.JInternalFrame;
import javax.swing.text.MaskFormatter;

/**
 *
 * @author Vanessa
 */
public class JP_RegistrarAccion_Reapertura extends JP_Utiles_PanelModelo {

    /** Creates new form JP_RegistraAccion */
    public JP_RegistrarAccion_Reapertura() {
        inicializaComponentes();
    }

    private void inicializaComponentes(){
        initComponents();
       

        //Panel de Operaciones
        ArrayList alBotones = new ArrayList( 1 );
        alBotones.add( new Integer( JP_Utiles_PanelBotonesMantenimiento.BOTON_GUARDAR ) );
        alBotones.add( new Integer( JP_Utiles_PanelBotonesMantenimiento.BOTON_LIMPIAR ) );
        alBotones.add( new Integer( JP_Utiles_PanelBotonesMantenimiento.BOTON_CERRAR ) );

        jp_ope = new JP_Utiles_PanelBotonesMantenimiento( this, alBotones );
        jp_Operaciones.setLayout( new BorderLayout() );
        jp_Operaciones.add( jp_ope, BorderLayout.CENTER );            
        this.cargaComboArea();
        //this.habilitarPestania(0); //No habilitamos pestanias
              
    }

    public JP_Utiles_PanelBotonesMantenimiento getJp_ope() {
        return jp_ope;
    }

    public void setJp_ope(JP_Utiles_PanelBotonesMantenimiento jp_ope) {
        this.jp_ope = jp_ope;
    }
    
    private void cargaComboArea(){        
        List listTbArea = null; // seteamos variable local
        List listaArea = comboBeanBindingArea1.getLista();
        listaArea.clear();
        try {
            listTbArea = GestionDelegate.getInstance().getListaArea();
        } catch (Exception e) {
            System.out.println( "Error en gestionDelegate.getListaArea()" );
            return;
        }
        this.comboBeanBindingArea1.setLista(listTbArea);
        this.bindingGroup.bind();
        this.cmbArea.updateUI();
        if( listTbArea.size() > 0 ){
            this.cmbArea.setSelectedIndex( 0 );
        }
    }

    private void cargaTabla(){
        String fecha, log_user;

        fecha = this.ftxtFecha.getText().trim();
        log_user = ControlAccionesComercialApp.LOG_USER;

        Utiles_Fecha_Cliente fecIni = new Utiles_Fecha_Cliente(fecha);
        if( !fecIni.isValida() ){
            Utiles_MensajesDialogo.mensajeAlerta("Ingrese una fecha valida");
            return;
        }

        try {
            listaDatos = GestionDelegate.getInstance().getListaReaperturas(fecha, log_user);
        } catch (Exception ex) {
            //Logger.getLogger(JP_ListarAcciones_Area.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println( "Error al listar acciones: " + ex.getMessage() );
        }

        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
        jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ, listaDatos, this.tbData);

        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding0 = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${idReapertura}"));
        columnBinding0.setColumnName("Id.");
        columnBinding0.setColumnClass(Integer.class);
        columnBinding0.setEditable(false);

        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding1 = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${inscrinro}"));
        columnBinding1.setColumnName("Numero de inscripcion");
        columnBinding1.setColumnClass(BigInteger.class);
        columnBinding1.setEditable(false);

        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding2 = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nombre}"));
        columnBinding2.setColumnName("Nombre");
        columnBinding2.setColumnClass(String.class);
        columnBinding2.setEditable(false);

        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding3 = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${fecha}"));
        columnBinding3.setColumnName("Fecha");
        columnBinding3.setColumnClass(String.class);
        columnBinding3.setEditable(false);

        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding4 = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${sercod}"));
        columnBinding4.setColumnName("Cod servicio");
        columnBinding4.setColumnClass(Long.class);
        columnBinding4.setEditable(false);

        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding5 = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${serdesc}"));
        columnBinding5.setColumnName("Servicio");
        columnBinding5.setColumnClass(String.class);
        columnBinding5.setEditable(false);

        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding6 = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${cod_tipo_accion}"));
        columnBinding6.setColumnName("Tipo Accion");
        columnBinding6.setColumnClass(Integer.class);
        columnBinding6.setEditable(false);

        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding7 = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${log_user}"));
        columnBinding7.setColumnName("Log_User");
        columnBinding7.setColumnClass(String.class);
        columnBinding7.setEditable(false);

        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding8 = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${flagRegistrada}"));
        columnBinding8.setColumnName("Registrada");
        columnBinding8.setColumnClass(Boolean.class);
        columnBinding8.setEditable(false);

        bindingGroup.addBinding(jTableBinding);
        bindingGroup.bind();
    }

   public void inicializaReferencias(){
//        jp_dc.setRef(getRef());
//        jp_dc.setRefDep(this);
//        jp_ma.setRef(getRef());
//        jp_ma.setRefDep(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always re-generated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        comboBeanBindingTbTipoAccionClasificacionAccionArea1 = new beansbinding.ComboBeanBindingTbTipoAccionClasificacionAccionArea();
        comboBeanBindingArea1 = new beansbinding.ComboBeanBindingArea();
        buttonGroup1 = new javax.swing.ButtonGroup();
        jp_DocumentoIdentificacion = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        cmbArea = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        atxtObservacion = new javax.swing.JTextArea();
        jLabel4 = new javax.swing.JLabel();
        try{
            this.mascara = new javax.swing.text.MaskFormatter("##/##/####");            
        }catch(Exception e){
        }
        ftxtFecha = new javax.swing.JFormattedTextField();
        this.ftxtFecha = new javax.swing.JFormattedTextField(mascara);
        btnVerArchivo = new javax.swing.JButton();
        jp_Operaciones = new javax.swing.JPanel();
        jp_Derechohabientes = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbData = new javax.swing.JTable();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(controlaccionescomercial.ControlAccionesComercialApp.class).getContext().getResourceMap(JP_RegistrarAccion_Reapertura.class);
        jp_DocumentoIdentificacion.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jp_DocumentoIdentificacion.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jp_DocumentoIdentificacion.border.titleFont"))); // NOI18N
        jp_DocumentoIdentificacion.setName("jp_DocumentoIdentificacion"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        cmbArea.setName("cmbArea"); // NOI18N

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, comboBeanBindingArea1, eLProperty, cmbArea);
        bindingGroup.addBinding(jComboBoxBinding);

        cmbArea.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbAreaActionPerformed(evt);
            }
        });
        cmbArea.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                cmbAreaKeyPressed(evt);
            }
        });

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        atxtObservacion.setColumns(20);
        atxtObservacion.setRows(5);
        atxtObservacion.setName("atxtObservacion"); // NOI18N
        atxtObservacion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                atxtObservacionKeyPressed(evt);
            }
        });
        jScrollPane1.setViewportView(atxtObservacion);

        jLabel4.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        ftxtFecha.setText(resourceMap.getString("ftxtFecha.text")); // NOI18N
        ftxtFecha.setName("ftxtFecha"); // NOI18N
        ftxtFecha.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                ftxtFechaFocusLost(evt);
            }
        });
        ftxtFecha.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                ftxtFechaKeyPressed(evt);
            }
        });

        btnVerArchivo.setFont(resourceMap.getFont("btnVerArchivo.font")); // NOI18N
        btnVerArchivo.setIcon(resourceMap.getIcon("btnVerArchivo.icon")); // NOI18N
        btnVerArchivo.setText(resourceMap.getString("btnVerArchivo.text")); // NOI18N
        btnVerArchivo.setName("btnVerArchivo"); // NOI18N
        btnVerArchivo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVerArchivoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jp_DocumentoIdentificacionLayout = new javax.swing.GroupLayout(jp_DocumentoIdentificacion);
        jp_DocumentoIdentificacion.setLayout(jp_DocumentoIdentificacionLayout);
        jp_DocumentoIdentificacionLayout.setHorizontalGroup(
            jp_DocumentoIdentificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jp_DocumentoIdentificacionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jp_DocumentoIdentificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jp_DocumentoIdentificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cmbArea, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jp_DocumentoIdentificacionLayout.createSequentialGroup()
                        .addComponent(ftxtFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(120, 120, 120)
                        .addComponent(btnVerArchivo, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 567, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(19, Short.MAX_VALUE))
        );
        jp_DocumentoIdentificacionLayout.setVerticalGroup(
            jp_DocumentoIdentificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jp_DocumentoIdentificacionLayout.createSequentialGroup()
                .addGroup(jp_DocumentoIdentificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(cmbArea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jp_DocumentoIdentificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(ftxtFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnVerArchivo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jp_DocumentoIdentificacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jp_Operaciones.setName("jp_Operaciones"); // NOI18N

        javax.swing.GroupLayout jp_OperacionesLayout = new javax.swing.GroupLayout(jp_Operaciones);
        jp_Operaciones.setLayout(jp_OperacionesLayout);
        jp_OperacionesLayout.setHorizontalGroup(
            jp_OperacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 720, Short.MAX_VALUE)
        );
        jp_OperacionesLayout.setVerticalGroup(
            jp_OperacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jp_Derechohabientes.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jp_Derechohabientes.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jp_Derechohabientes.border.titleFont"))); // NOI18N
        jp_Derechohabientes.setName("jp_Derechohabientes"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        tbData.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tbData.setName("tbData"); // NOI18N
        jScrollPane2.setViewportView(tbData);

        javax.swing.GroupLayout jp_DerechohabientesLayout = new javax.swing.GroupLayout(jp_Derechohabientes);
        jp_Derechohabientes.setLayout(jp_DerechohabientesLayout);
        jp_DerechohabientesLayout.setHorizontalGroup(
            jp_DerechohabientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 708, Short.MAX_VALUE)
        );
        jp_DerechohabientesLayout.setVerticalGroup(
            jp_DerechohabientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jp_Operaciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jp_DocumentoIdentificacion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jp_Derechohabientes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jp_DocumentoIdentificacion, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jp_Derechohabientes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(50, 50, 50)
                .addComponent(jp_Operaciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        bindingGroup.bind();
    }// </editor-fold>//GEN-END:initComponents

    private void cmbAreaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbAreaActionPerformed
        if( this.cmbArea.getSelectedItem() != null ){
            this.ftxtFecha.requestFocus();
        }
    }//GEN-LAST:event_cmbAreaActionPerformed

    private void cmbAreaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cmbAreaKeyPressed
        if( evt.getKeyCode() == evt.VK_ENTER ){
            this.ftxtFecha.requestFocus();
        }
    }//GEN-LAST:event_cmbAreaKeyPressed

    private void atxtObservacionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_atxtObservacionKeyPressed
        if( evt.getKeyCode() == evt.VK_ENTER ){            
        }
    }//GEN-LAST:event_atxtObservacionKeyPressed

    private void ftxtFechaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ftxtFechaKeyPressed
        if( evt.getKeyCode() == evt.VK_ENTER ){
            this.btnVerArchivo.requestFocus();
        }
    }//GEN-LAST:event_ftxtFechaKeyPressed

    private void ftxtFechaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_ftxtFechaFocusLost
         
    }//GEN-LAST:event_ftxtFechaFocusLost

    private void btnVerArchivoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVerArchivoActionPerformed
        habilitarComponentes( false );
        mostrarReaperturas();
        habilitarComponentes( true );
        this.atxtObservacion.requestFocus();
    }//GEN-LAST:event_btnVerArchivoActionPerformed

    public void habilitarComponentes( boolean ban){
        this.cmbArea.setEnabled(ban);
        this.ftxtFecha.setEnabled(ban);
        this.atxtObservacion.setEnabled(ban);
        this.jp_Operaciones.setEnabled(ban);
        this.btnVerArchivo.setEnabled(ban);
    }
    public void mostrarReaperturas(){
        String rpta = "";
        TbArea seleccionado;
        seleccionado = (TbArea) this.cmbArea.getSelectedItem();
        cod_area = seleccionado.getCodArea();
        fec_Proceso = this.ftxtFecha.getText().trim();
        log_user = ControlAccionesComercialApp.LOG_USER;
        obser =  this.atxtObservacion.getText().trim();
         //Ejecutar integracion
        try {
            if(!GestionDelegate.getInstance().seEstaEjecutandoJob("R") ){
                rpta = GestionDelegate.getInstance().ejecutarIntegracionReaperturas();
                if( rpta.equalsIgnoreCase("bien")){
                    rpta = GestionDelegate.getInstance().copiarReaperturas(fec_Proceso, log_user);
                    if( rpta.equalsIgnoreCase("bien")){
                        //Cargar tabla de Reaperturas segun los datos ingresados
                        cargaTabla();
                    }else{
                        helper.Utiles_MensajesDialogo.mensajeError( "Error al ejecutar la copia de la integracion" );
                    }
                }else{
                    helper.Utiles_MensajesDialogo.mensajeFracaso( "Error al ejecutar el proceso de integracion--->" + rpta );
                }
            }else{
                helper.Utiles_MensajesDialogo.mensajeAlerta( "Ya se esta ejecutando el trabajo de integracion" );
            }
        } catch (SQLException ex) {
            Logger.getLogger(JP_RegistrarAccion_Reapertura.class.getName()).log(Level.SEVERE, null, ex);
        }        
    }
    @Override
    public Task guardar() {
        return new Guarda(org.jdesktop.application.Application.getInstance(controlaccionescomercial.ControlAccionesComercialApp.class));        
    }
    
    private class Guarda extends org.jdesktop.application.Task<Object, Void> {
        Guarda(org.jdesktop.application.Application app) {
            super(app);
        }
        @Override protected Object doInBackground() {
            jp_ope.getBtnGuardar().setEnabled(false);
            ((JInternalFrame)getPadre()).setEnabled(false);
            guardarSegundoPlano();
            ((JInternalFrame)getPadre()).setEnabled(true);
            return null;  // return your result
        }
        @Override protected void succeeded(Object result) {
        }
    }

    public void guardarSegundoPlano(){
        String rpta = "";
        TbArea seleccionado;
        seleccionado = (TbArea) this.cmbArea.getSelectedItem();
        cod_area = seleccionado.getCodArea();
        fec_Proceso = this.ftxtFecha.getText().trim();
        log_user = ControlAccionesComercialApp.LOG_USER;
        obser =  this.atxtObservacion.getText().trim();
        try{
            //Ejecutar el procedimiento Procesar Reaperturas
            rpta = GestionDelegate.getInstance().procesarReaperturas(cod_area, fec_Proceso, log_user, obser);
            if( rpta.equalsIgnoreCase("bien")){
                helper.Utiles_MensajesDialogo.mensajeExito();
                cargaTabla();
            }else{
                helper.Utiles_MensajesDialogo.mensajeFracaso(rpta);
            }
           limpiarRegistro();
        }catch( Exception ex ){
            ex.printStackTrace();
            jp_ope.getBtnGuardar().setEnabled(true);
            Utiles_MensajesDialogo.mensajeError("Error al realizar la operación");
        }
    }

    public void limpiarRegistro(){
        this.jp_ope.getBtnGuardar().setEnabled(true);        
        this.atxtObservacion.setText("");
        this.cmbArea.setSelectedIndex(0);                
        this.ftxtFecha.setText( "" );
        this.cmbArea.requestFocus();
    }

    @Override
    public Task limpiar() {
        limpiarRegistro();
        //this.cmbTipoAccion.setSelectedIndex(-1);
        return null;
    }
    
    @Override
    public Task cerrar() {
        this.cerrarPadre();
        return null;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea atxtObservacion;
    private javax.swing.JButton btnVerArchivo;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JComboBox cmbArea;
    private beansbinding.ComboBeanBindingArea comboBeanBindingArea1;
    private beansbinding.ComboBeanBindingTbTipoAccionClasificacionAccionArea comboBeanBindingTbTipoAccionClasificacionAccionArea1;
    private javax.swing.JFormattedTextField ftxtFecha;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JPanel jp_Derechohabientes;
    private javax.swing.JPanel jp_DocumentoIdentificacion;
    private javax.swing.JPanel jp_Operaciones;
    private javax.swing.JTable tbData;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
    private JP_Utiles_PanelBotonesMantenimiento jp_ope;
    
    private org.jdesktop.swingbinding.JTableBinding jTableBinding;
    private List<TableBeanBinding_DatosReaperturas> listaDatos;
    private MaskFormatter mascara;
    String cod_area;
    String fec_Proceso;
    String log_user;
    String obser;
}
